//
//  AppDelegate.swift
//  ios-python
//
//  Created by mac on 2024/12/11.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // 初始化 Python 解释器
        PythonManager.initializePythonInterpreterWithArgc()
        print("Python interpreter initialized successfully!")
        
        return true
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // 释放 Python 解释器
        PythonManager.finalizePythonInterpreter()
        print("Python interpreter finalized.")
    }

    // MARK: UISceneSession Lifecycle

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    @available(iOS 13.0, *)
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // 释放与丢弃的 Scene 会话相关的资源（如果需要）
    }
}
